home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / pdcurs21.zip / PRIVATE.ZIP / _CATTR.C < prev    next >
Text File  |  1992-11-21  |  3KB  |  86 lines

  1. #define        CURSES_LIBRARY  1
  2. #include <curses.h>
  3.  
  4. #ifndef NDEBUG
  5. char *rcsid__cattr = "$Header: c:/curses/private/RCS/_cattr.c%v 2.0 1992/11/15 03:24:41 MH Rel $";
  6. #endif
  7.  
  8.  
  9.  
  10.  
  11. /*man-start*********************************************************************
  12.  
  13.   PDC_chg_attr_pair()  - Writes character and attribute to physical screen
  14.  
  15.   PDCurses Description:
  16.        This is a private PDCurses function.
  17.  
  18.        Writes a single character 'chr' with attribute 'attr' to the
  19.        current cursor location.
  20.  
  21.        NOTE:   Though passed as 16 bit quantities, only the lower 8 bits
  22.                will be used to create a character/attribute pair.
  23.  
  24.   PDCurses Return Value:
  25.        This function returns OK on success and ERR on error.
  26.  
  27.   PDCurses Errors:
  28.        No errors are defined for this function under DOS.
  29.  
  30.        An ERR may be returned under FLEXOS if s_copy() fails.  See the
  31.        Flexos Programmer's Reference Manual for details on the error.
  32.  
  33.   Portability:
  34.        PDCurses        int PDC_chg_attr_pair( chtype chr, chtype attr );
  35.  
  36. **man-end**********************************************************************/
  37.  
  38. int    PDC_chg_attr_pair(chtype chr, chtype attr)
  39. {
  40.        extern unsigned char atrtab[MAX_ATRTAB];
  41.        chtype  phys_attr=chtype_attr(attr);
  42.  
  43. #ifdef FLEXOS
  44.        UBYTE   c = (UBYTE) chr;
  45.        UBYTE   a = (UBYTE) phys_attr;
  46.  
  47.        drect.r_row = PDC_get_cur_row();
  48.        drect.r_col = PDC_get_cur_col();
  49.        drect.r_nrow = 1;
  50.        drect.r_ncol = 1;
  51.  
  52.        sframe.fr_pl[0] = (UBYTE *) & c;
  53.        sframe.fr_pl[1] = (UBYTE *) & a;
  54.        sframe.fr_pl[2] = (UBYTE *) " ";
  55.        sframe.fr_nrow = 1;
  56.        sframe.fr_ncol = 1;
  57.        sframe.fr_use = 0x00;
  58.  
  59.        srect.r_col = 0;
  60.        srect.r_row = 0;
  61.        srect.r_nrow = 1;
  62.        srect.r_ncol = 1;
  63.  
  64.        retcode = s_copy(0x03, 0x01L, 0L, (far unsigned short *) &drect, (far unsigned short *) &sframe, (far unsigned short *) &srect);
  65.        return( (retcode < 0L) ? ERR : OK );
  66. #endif
  67. #ifdef DOS
  68.        regs.h.ah = 0x09;
  69.        regs.h.al = chr & A_CHARTEXT;
  70.        regs.h.bh = _cursvar.video_page;
  71.        regs.h.bl = (phys_attr & A_ATTRIBUTES) >> 8;
  72.        regs.x.cx = 0x01;
  73.        int86(0x10, ®s, ®s);
  74.        return( OK );
  75. #endif
  76. #ifdef OS2
  77.        USHORT curCol, curRow, cell;
  78.        
  79.        /* find the current cursor position */
  80.        VioGetCurPos((PUSHORT) &curRow, (PUSHORT) &curCol, 0);
  81.        cell = (chr & A_CHARTEXT) | (phys_attr & A_ATTRIBUTES);
  82.        VioWrtNCell((PBYTE)&cell,1,curRow,curCol,0);
  83.        return( OK );
  84. #endif
  85. }
  86.